<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Exportorder_Remote extends CI_Controller {

	/**
	 * 
	 *  自动导单程序 
	 *  远程 速卖通 /exportorder_remote/ajaxbutton?op=doInsertOrderDatapro
	 *  远程 Wish  /exportorder_remote/ajaxbutton?op=wishorderlist
	 *  远程 Ebay
	 */
	function __construct()
	 {
		 parent::__construct();
		 $this->load->model('Function_m','fun');
		 $this->load->model('Exportorder_m','m');
		  $this->load->model('Deliverorder_m','d');
		 $this->pageSize =$this->config->item('pagenum');
	 }
	 
	function ajaxbutton()
	{
		$op = $this->input->get_post('op');
		
		/******************************************************************
		**  导出远程Wish订单数据
		**  liuxiang 2017 08 06
		**  library 
		****************************************************************/
		if($op =='wishorderlist')	
		{
			$this->load->library('Wishdata_Remote');
			$ress = $this->wishdata_remote->getinsertdata();
			$this->wishdata_remote->getinsertrefunddata();//更新退款信息
			if($ress == false)
			{
				echo "OK";
				die;
			}
			
		}
		/******上传wish信息到远程数据库等待同步******/
		if($op =='wishuploadreturn')	
		{
			$this->load->library('Wishdata_Remote');
			$ress = $this->wishdata_remote->wishreturn();
			if($ress == false)
			{
				echo "OK";
				die;
			}
		}
		/********Wish 操作结束******************/
		

		/******************************************************************
		**  导出远程速卖通订单数据
		**  liuxiang 2017 08 06
		**  library 
		****************************************************************/
		
		if($op =='doInsertOrderDatapro')	//下载订单
		{
			$this->load->library('AliexpressdataPro');
			$ress = $this->aliexpressdatapro->doInsertOrderData();
			if($ress == false)
			{
				echo "OK";
				die;
			}
		}
		if($op =='aliexpresswuyou')		//获取无忧交运信息
		{
			$this->load->library('AliexpressdataPro');
			$ress = $this->aliexpressdatapro->aliexpresswuyou();
			if($ress == false)
			{
				echo "OK";
				die;
			}
		}

		if($op =='createSendGoodsOrderOnline')	//Erp处理完订单信息，将运单号回传到速卖通
		{
			$this->load->library('AliexpressdataPro');
			$ress = $this->aliexpressdatapro->createSendGoodsOrderOnline();
			if($ress == false)
			{
				echo "OK";
				die;
			}
			
		}
		/******************速卖通结束**************************/
		
		/******************************************************************
		**  导出远程Ebay订单数据
		**  liuxiang 2017 08 06
		**  library 
		****************************************************************/
		
		if($op =='GetEbayInsertOrder')	//下载订单
		{
			$this->load->library('Ebaydata_Remote');
			$ress = $this->ebaydata_remote->GetEbayInsertOrder();
			if($ress == false)
			{
				echo "OK";
				die;
			}
		}
		/*************回传物流单号****************/
		if($op =='Ebayreturn')
		{
			$this->load->library('Ebaydata_Remote');
			$ress = $this->ebaydata_remote->Ebayreturn();
			if($ress == false)
			{
				echo "OK";
				die;
			}
		}
		 //cnpost remote交运获取数据，更新到正式db_order_list db_mabangorder相关表
        if($op=='remotecnpostexpress'){
            $res = $this->d->remotecnpostexpress();
        }

	}


}
